<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="javabean.*"%>
<%@page import="javabean.book.*"%>
<!DOCTYPE html>
<html lang="zh-cn">
	<%
		String uid = (String) session.getAttribute("uid");
		Book book = (Book)request.getAttribute("book");
		long  bid = book.getBid() ;
		String isbn = book.getIsbn() ;
		String bname = book.getBname() ;
		String author = book.getAuthor() ;
		String publisher = book.getPublisher() ;
		String years = book.getYears() ;
		String revision = book.getRevision() ;
		String belong = book.getBelong();
		String exterior = book.getExterior() ;
		String picname = book.getPicname();
		String picurl = book.getPicurl() ;
		String other = book.getOther()==null?"":book.getOther() ;
		String type = book.getType();
		int quantity = book.getQuantity() ;
	%>
    <head>
    	<title>编辑图书</title>
    	<meta charset="utf-8">
        <link rel="stylesheet" type="text/css" href="/bookcrossing/css/bootstrap.min.css" />
        <link rel="stylesheet" type="text/css" href="/bookcrossing/css/main.css">
        <link rel="stylesheet" type="text/css" href="/bookcrossing/css/book.css">
        <link rel="shortcut icon" type="image/png" href="/bookcrossing/img/favicon.png" />
	</head>
	<body>
		<%if(uid.equals(belong)){ %>
		<jsp:include page="../public/head.jsp"></jsp:include>
		<div class="modal fade" id="dialog-box">
	    	<div class="modal-dialog">
	    		<div class="modal-content">
	    			<div class="modal-body">
	    				<span class="tips-pic"></span> 
	    				<span class="tips-content"></span>
	    			</div>
	    			<div class="modal-footer">
	    				<button type="button" class="btn btn-info btn-sm" data-dismiss="modal">好滴</button>
	    			</div>
	    		</div>
	    	</div>
	    </div>
		<div class="container book-add-container">
			<a href="javascript:history.go(-1);" class="go-back"><< 返回上一页</a>
			<h3 class="b-a-title">编辑图书</h3>
			<div class="b-a-content">
				
				<form id="b-a-form" class="form-horizontal b-a-form" name="b-a-form" action="addBook">
					<input type="hidden" name="bid" class="bid" value="<%=bid %>"/>
					<div class="pic-wrap">
						<div class="pic-show">
							<img src="/bookcrossing/img/book/<%=picurl %>" alt="图书封面" class="pre-img"/>
							<p>支持jpg,png,gif (小于1.5M)</p>
						</div>
						<div class="pic-input-wrap">
							<button type="button" class="btn btn-info btn-sm upload-btn"/>
								<span class="glyphicon glyphicon-upload"></span> 重传封面
							</button>
							<input type="file" name="pic" class="pic" id="pic" accept="image/jpeg,image/gif,image/png" multiple/>
						</div>
					</div>
					<div class="form-group">
					    <label for="isbn" class="col-sm-2 control-label"><span class="countdown">* </span>ISBN</label>
					    <div class="col-sm-5">
					      <input type="text" class="form-control isbn" id="isbn" name="isbn" value="<%=isbn %>" placeholder="在书本背面哦，省略''_''" >
					    </div>
					</div>
					<div class="form-group">
					    <label for="bname" class="col-sm-2 control-label"><span class="countdown">* </span>书名</label>
					    <div class="col-sm-5">
					      <input type="text" class="form-control bname" id="bname" name="bname" value="<%=bname %>" placeholder="你知道的" >
					    </div>
					</div>
					<div class="form-group">
					    <label for="author" class="col-sm-2 control-label"><span class="countdown">* </span>作者</label>
					    <div class="col-sm-5">
					      <input type="text" class="form-control author" id="author" name="author" value="<%=author %>" placeholder="哪位大师的书" >
					    </div>
					</div>
					<div class="form-group">
					    <label for="author" class="col-sm-2 control-label"><span class="countdown">* </span>分类</label>
					    <div class="col-sm-5">
					      <select class="form-control type" id="type" name="type" >
					      	<option value="请选择...">请选择...</option>
					      	<%
						      	List<BookTag> bookTag = null ;
			        			try{
			        				bookTag = Factory.getBookDAOInstance().queryAllBookTag();
			        			}catch(Exception ex){}
			        			Iterator<BookTag> tagIter = bookTag.iterator() ;
			        			while(tagIter.hasNext()){
			        				BookTag book_tag = (BookTag)tagIter.next();
        							String tagName = book_tag.getTagname();
        							String selected = "";
        							if(tagName.equals(type)){
        								selected = "selected";
        							}
					      	%>
					      		<option value="<%=tagName %>" <%=selected %>><%=tagName %></option>
					      	<%} %>
					      </select>
					    </div>
					</div>
					<div class="form-group">
					    <label for="publisher" class="col-sm-2 control-label"><span class="countdown">* </span>出版社</label>
					    <div class="col-sm-5">
					      <input type="text" class="form-control publisher" id="publisher" value="<%=publisher %>" name="publisher" placeholder="出自哪里" >
					    </div>
					</div>
					<div class="form-group">
					    <label for="years" class="col-sm-2 control-label">出版年</label>
					    <div class="col-sm-9">
					      <input type="text" class="form-control years" id="years" name="years" value="<%=years %>" placeholder="什么时候出版的口尼">
					    </div>
					</div>
					<div class="form-group">
					    <label for="revision" class="col-sm-2 control-label">版次</label>
					    <div class="col-sm-9">
					      <input type="text" class="form-control revision" id="revision" name="revision" value="<%=revision %>" placeholder="第几版了">
					    </div>
					</div>
					<div class="form-group">
					    <label for="exterior" class="col-sm-2 control-label">外观</label>
					    <div class="col-sm-9">
					      <input type="text" class="form-control exterior" id="exterior" name="exterior" value="<%=exterior %>" placeholder="不会看不出来吧..">
					    </div>
					</div>
					<div class="form-group">
					    <label for="quantity" class="col-sm-2 control-label">数量</label>
					    <div class="col-sm-9">
					      <input type="text" class="form-control quantity" id="quantity" value="<%=quantity %>" name="quantity">
					    </div>
					</div>
					<div class="form-group">
					    <label for="other" class="col-sm-2 control-label">简介</label>
					    <div class="col-sm-9">
					      <textarea class="form-control other" id="other" name="other" rows="4" placeholder="写点啥吧，会在首页展示哦 ^_^"><%=other %></textarea>
					    </div>
					</div>
					<input type="hidden" name="belong" class="belong" value="<%=belong%>"/>
					<input type="hidden" name="oldpicname" class="old-pic-name" value="<%=picname%>"/>
	  				<input type="hidden" name="oldpicurl" class="old-pic-url" value="<%=picurl%>"/>
					<button type="submit" class="btn btn-primary submit" name="submit" id="submit">修改</button>
					</div>
				</form>
			</div>
		</div>
		<jsp:include page="../public/foot.jsp"></jsp:include>
		<script src="/bookcrossing/js/jquery-1.9.1.min.js" type="text/javascript"></script>
        <script src="/bookcrossing/js/bootstrap.min.js" type="text/javascript" ></script>
        <script src="/bookcrossing/js/common.js" type="text/javascript" ></script>
        <script src="/bookcrossing/js/book-edit.js" type="text/javascript" ></script>
        <%}else{%>
        	<jsp:forward page="/" />
        <%} %>
	</body>